<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Message extends Model
{
    protected $fillable = [
        'user_id',
        'title',
        'content',
        'remarks',
        'type',
        'is_read',
    ];

    protected $casts = [
        'is_read' => 'boolean',
    ];

    static $IS_READ_MAP = [
        '否', '是',
    ];

    const SYS = 'sys';

    const ORDER = 'order';

    static $TYPE_MAP = [
        self::SYS => '系統',
        self::ORDER => '訂單',
    ];

    public function messages()
    {
        return $this->belongsTo(Message::class, 'id', 'user_id');
    }
}
